<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>
    	<spring:message code="head.clothGarment"></spring:message>-
    	<spring:message code="head.subjectClassification"></spring:message>-
    	<spring:message code="head.patternList"></spring:message>
    </title>
    <!--公共样式-->
    <link href="${pageContext.request.contextPath }/web/css/font/iconfont.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/NormalizeFile.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/public.css" />
    <!--列表页面私有样式-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/subpage/list.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/h-ui/layui-v1.0.2/layui/css/layui.css" />
</head>
<body>
<jsp:include page="../main/head.jsp"></jsp:include>
<!--列表 begin-->
<div class="contenter mt134">
    <c:if test="${not empty theme }">
    <ul class="sub-info-list">
        <li>
            <div class="sub-info-list-br"><div class="sub-info-list-img"><img src="${pageContext.request.contextPath }/upload/${theme.img }" /></div></div>
            <div class="sub-info-list-cont">
	            <h2 class="sub-info-title">${theme.name }</h2>
	            <h2 class="sub-subhead">${theme.nameEn }</h2>
	            <p>
	            	<div class="info" title="${theme.info }"></div>
	            </p>
            </div>
            <div class="clearfix"></div>
        </li>
    </ul>
    </c:if>
    <!--图文列表 begin-->
    <c:if test="${not empty pList }">
    <ul class="index-exploit-list">
    	<c:forEach items="${pList }" var="p">
        <li>
        	<a href="javascript:xiangqing('${p.isVip}','${p.pId}')" onfocus="blur();">
	        	<div class="list-bor">
	        		<img src="${p.pImg }" />
	       		</div>
	       		<div class="screening-condition-name">
	       			<div class="serial-number"><spring:message code="subjectClassificationDetails.number"></spring:message>：${p.pNo }</div>
	       			<c:if test="${p.isVip==2 }"><div class="serial-vip serialvipt">VIP</div></c:if>
	       			<div class="clearfix"></div>
	       			<div class="serial-size"><spring:message code="subjectClassificationDetails.size"></spring:message>：${p.chicun }cm</div>
	   			</div>
   			</a>
   			<div class="list-exploit-like" onclick="attention(2,${p.pId});">
				<c:if test="${not empty member }">
					<c:if test="${member.mId==p.mId }">
						<img id="attImg${p.pId}" src="${pageContext.request.contextPath }/web/img/icon_alreadycollected.png" />
					</c:if>
					<c:if test="${member.mId!=p.mId }">
						<img id="attImg${p.pId}" src="${pageContext.request.contextPath }/web/img/icon_addcollection.png" />
					</c:if>
				</c:if>	
				<c:if test="${empty member }">
					<img id="attImg${p.pId}" src="${pageContext.request.contextPath }/web/img/icon_addcollection.png" />
				</c:if>
			</div>
		</li>
		</c:forEach>
    </ul>
    </c:if>
    <c:if test="${page.totalPage>1 }">
    	<div id="demo3"></div>
    	<div class="clearfix"></div>
    </c:if>
    <!--图文列表 end-->
    <form action="${pageContext.request.contextPath }/web/theme/details" method="get" id="pageForm">
		 <input type="hidden" id="currentPage" name="page" value="${page.page}"/>
		 <input type="hidden" id="id" name="id" value="${theme.id }"/>
    </form>
</div>
<!--列表 end-->
<jsp:include page="../main/bottom.jsp"></jsp:include>
<!--全局-->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/public.js"></script>
<!--ie789下placeholder不兼容-->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/placeholder.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/layui-v1.0.2/layui/layui.js"></script>
<script language="JavaScript" type="text/JavaScript">

	$(function(){
		
		var infoObjs=$('.info');
		infoObjs.each(function(){
			var titleString=$(this).attr('title');
			if(titleString.length>280){
				var titleSub=titleString.substring(0,280);
				$(this).text(titleSub+'...');
			}else{
				$(this).text(titleString);
			}
		});
		
	});

	function gotoPage(pagenum){
	  $("#currentPage").val(pagenum);
	  $("#pageForm").submit();
	}
	//分页初始化
    layui.use(['laypage', 'layer'], function(){
    	  var laypage = layui.laypage
    	  ,layer = layui.layer;
    	  laypage({
    	    cont: 'demo3'
    	    ,pages: $("#tottalPage").val()
    	    ,first: 1
    	    ,groups:5
    	    ,curr:$("#currentPage").val()
    	    ,skin: 'molv' //皮肤
    	    ,last: $("#tottalPage").val()
    	    ,prev: '<em><</em>'
    	    ,next: '<em>></em>'
    	    ,jump: function(obj, first){
    	        var curr = obj.curr;
    	        if(!first){ //一定要加此判断，否则初始时会无限刷新    
    	        	gotoPage(curr);    
                }
    	      }
    	  });
    	  
    	});
	
	//关注
    function attention(type,aId){
    	$.ajax( {  
    		type : "POST",  
             url : "${pageContext.request.contextPath }/member/member/attention",
             data : {type:type,aId:aId},
             success: function(data) {
            	 if(data == 1){//取消关注成功
            		 layer.msg('<spring:message code="caozuochenggong"></spring:message>',{icon:1,time:1000});
            		 $("#attImg"+aId).attr('src','${pageContext.request.contextPath }/web/img/icon_addcollection.png');  
            	 }else if(data == 2){//关注成功
            		 layer.msg('<spring:message code="caozuochenggong"></spring:message>',{icon:1,time:1000});
            		 $("#attImg"+aId).attr('src','${pageContext.request.contextPath }/web/img/icon_alreadycollected.png');
            	 }else{
            		 layer.msg('<spring:message code="caozuoshibai"></spring:message>',{icon:1,time:1000});
            	 }
             }
    	});
    }
	
    function xiangqing(vip,patternId){
		if(vip==2){
		$.ajax({url:'${pageContext.request.contextPath }/web/patternfilter/judge', async : false,type : "POST",  success :function(result){
			 var status=result.msg.status;
			 var desc=result.msg.desc;
			    if(status == 1){//没登录
			    	layer.confirm('<spring:message code="flowertypecatalog.notLogin"></spring:message>', {
		        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
		        	  title:'<spring:message code="flowertypecatalog.message"></spring:message>'
		        	}, function(index){
		        		location.href="${pageContext.request.contextPath}/web/member/login";
		        	},function(index){
		        		
		        	});
			    	flag=true;
			    }else if(status ==2){
			    	layer.confirm('<spring:message code="flowertypecatalog.applyForVIP"></spring:message>', {
			        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
			        	  title:'<spring:message code="flowertypecatalog.message"></spring:message>'
			        	}, function(index){
			        		location.href="${pageContext.request.contextPath}/web/vip/applicationForVIP";
			        		layer.close(index);
			        	},function(index){
			        		layer.close(index);
			        	});
			    	
			    }else{
			    	top.location.href='${pageContext.request.contextPath}/web/pattern/flowerCatalog?id='+patternId;
			    }
		  	}
		});
		}else{
			$.ajax({url:'${pageContext.request.contextPath }/web/patternfilter/judge', async : false,type : "POST",  success :function(result){
	   			 var status=result.msg.status;
	   			 var desc=result.msg.desc;
	   			    if(status == 1){//没登录
	   			    	layer.confirm('<spring:message code="flowertypecatalog.notLogin"></spring:message>', {
	   			        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
	   			        	title:'<spring:message code="flowertypecatalog.message"></spring:message>'
	   			        	}, function(index){
	   			        		location.href="${pageContext.request.contextPath}/web/member/login";
	   			        	},function(index){
	   			        		
	   			        	});
	   			    	
	   			    }else{
	   			    	top.location.href='${pageContext.request.contextPath}/web/pattern/flowerCatalog?id='+patternId;
	   			    }
		}
	});
		}
	}
</script>
</body>
</html>